<template>
  <div class="goodslistitem" @click="goodsitemclick">
    <img :src="isshowimg" alt="" />
    <div>
      <p>{{ goodsitem.title }}</p>
      <span class="price">¥ {{ goodsitem.price }} </span>
      <span class="collect"
        ><i class="iconfont icon-smile"></i>{{ goodsitem.cfav }}</span
      >
    </div>
  </div>
</template>

<script>
export default {
  // 组件名称
  name: "goodslistitem", // 组件参数 接收来自父组件的数据
  props: {
    goodsitem: {
      type: Object,
      default() {
        return {};
      },
    },
    id: {
      type: Number,
      default() {
        return null;
      },
    },
  }, // 局部注册的组件
  components: {}, // 组件状态值
  data() {
    return {};
  },
  computed: {
    isshowimg() {
      return this.goodsitem.image || this.goodsitem.show.img;
    },
  },
  methods: {
    goodsitemclick() {
      this.$router.push("/detail/" + this.goodsitem.iid);
    },
  },
};
</script>
<style scoped>
.goodslistitem {
  text-align: center;
  width: 50%;
}
.goodslistitem img {
  width: 180px;
  height: 220px;
  border-radius: 10px;
}
.goodslistitem p {
  overflow: hidden;

  text-overflow: ellipsis;

  display: -webkit-box;

  -webkit-line-clamp: 2;

  /*! autoprefixer: off */

  -webkit-box-orient: vertical;
}
.price {
  color: palevioletred;
}
.collect {
  color: orange;
}
i {
  vertical-align: middle;
}
</style>